<template>
	<button open-type="getPhoneNumber" class="phone-btn" @getphonenumber="getphonenumber" plain />
</template>

<script>
	import {
		wxma_login
	} from '@/api'
	import {
		mapActions
	} from 'vuex'
	export default {
		methods: {
			...mapActions(['getUserInfo']),
			async getphonenumber(obj) {
				if (obj.detail.errMsg === 'getPhoneNumber:ok') {
					try {
						const res = await wxma_login(obj.detail)
						this.getUserInfo()
						this.$emit('init')
					} catch (error) {}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.phone-btn {
		width: 100%;
		height: 100%;
		border: none;
	}
</style>